<template>
  <div class="top">
    <div class="left">
      <span class="lbtn" @click="goHome">首页</span>
    </div>
    <div class="center">智慧旅游可视化大数据平台</div>
    <div class="right">
      <span class="rbtn">统计报告</span>
      <span class="time">当前时间：{{ currentTime }}</span>
    </div>
  </div>
</template>

<script setup lang="ts" name="top">
import moment from 'moment'
import { useRouter } from 'vue-router'
import { onMounted, onBeforeUnmount, ref } from 'vue'
const router = useRouter()
const goHome = () => {
  router.push('/home')
}

let currentTime = ref(moment().format('YYYY年MM月DD日 HH:mm:ss'))
let timer = ref(0)

onMounted(() => {
  timer.value = setInterval(() => {
    currentTime.value = moment().format('YYYY年MM月DD日 HH:mm:ss')
  }, 1000)
})

onBeforeUnmount(() => {
  clearInterval(timer.value)
})
</script>

<style scoped lang="scss">
.top {
  height: 100px;
  display: flex;

  .left {
    flex: 1;
    background: url('../images/dataScreen-header-left-bg.png') no-repeat;
    background-size: cover;

    .lbtn {
      width: 150px;
      height: 100%;
      float: right;
      background: url('../images/dataScreen-header-btn-bg-l.png') no-repeat;
      background-size: cover;
      text-align: center;
      line-height: 40px;
      color: #29fcff;
      font-size: 20px;
    }
  }
  .center {
    flex: 2;
    background: url('../images/dataScreen-header-center-bg.png') no-repeat;
    background-size: cover;
    height: 74px;
    text-align: center;
    line-height: 74px;
    font-size: 30px;
    color: #29fcff;
  }
  .right {
    flex: 1;
    background: url('../images/dataScreen-header-right-bg.png') no-repeat;
    background-size: cover;
    color: #29fcff;
    font-size: 20px;
    text-align: center;
    line-height: 40px;
    display: flex;
    justify-content: space-between;
    .rbtn {
      width: 150px;
      height: 100%;
      background: url('../images/dataScreen-header-btn-bg-r.png') no-repeat;
      background-size: cover;
    }
    .time {
      font-size: 16px;
      margin-right: 10px;
    }
  }
}
</style>
